package com.base.controller;

import com.base.service.ScheduledTaskService;
import com.base.utils.Result;
import com.base.utils.ResultUtil;
import com.base.vo.SpringScheduledCron;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wnhuang
 * @Package com.base.controller
 * @date 2021-02-25 10:32
 */
@RestController
@RequestMapping("/scheduledTask")
public class TaskController {

    @Autowired
    ScheduledTaskService scheduledTaskService;

    @GetMapping("/getTaskList")
    public Result taskList() {
        return ResultUtil.success(scheduledTaskService.list());
    }

    @PostMapping("/saveTask")
    public Result saveTask(@RequestBody SpringScheduledCron scheduledCron) {
        return ResultUtil.success(scheduledTaskService.saveOrUpdate(scheduledCron));
    }
}
